package jmine.tec.test.metric.performance;

import java.math.BigDecimal;

import com.thoughtworks.xstream.annotations.XStreamAlias;
import com.thoughtworks.xstream.annotations.XStreamAsAttribute;

/**
 * Classe que representa tag performance do xml de performance
 * 
 * @author bruno.ortiz
 */
@XStreamAlias("performance")
public class Performance implements PerformanceInterface {

    private static final int DEFAULT_SCALE = 15;

    @SuppressWarnings("unused")
    @XStreamAlias("unit")
    @XStreamAsAttribute
    private String performanceUnit;

    @SuppressWarnings("unused")
    @XStreamAlias("mesure")
    @XStreamAsAttribute
    private BigDecimal performanceMesure;

    @SuppressWarnings("unused")
    @XStreamAlias("isRelevant")
    @XStreamAsAttribute
    private Boolean performanceIsRelevant;

    /**
     * Construtor da classe performance
     * 
     * @param performanceUnit Unidade de medida da tag performance do xml de performance.
     * @param performanceMesure Resultado da medida de performance da tag performance do xml de performance.
     * @param performanceIsRelevant Indica se a performance é relevante
     */
    public Performance(String performanceUnit, BigDecimal performanceMesure, Boolean performanceIsRelevant) {
        if (performanceMesure != null) {
            this.performanceMesure = performanceMesure.setScale(DEFAULT_SCALE, BigDecimal.ROUND_DOWN);
        } else {
            this.performanceMesure = null;
        }
        this.performanceUnit = performanceUnit;
        this.performanceIsRelevant = performanceIsRelevant;
    }

    /**
     * the performanceIsRelevant to set
     * 
     * @param performanceIsRelevant performanceIsRelevant
     */
    public void setPerformanceIsRelevant(Boolean performanceIsRelevant) {
        this.performanceIsRelevant = performanceIsRelevant;
    }

    /**
     * the performanceUnit to set
     * 
     * @param performanceUnit performanceUnit
     */
    public void setPerformanceUnit(String performanceUnit) {
        this.performanceUnit = performanceUnit;
    }

    /**
     * the performanceMesure to set
     * 
     * @param performanceMesure performanceMesure
     */
    public void setPerformanceMesure(BigDecimal performanceMesure) {
        if (performanceMesure != null) {
            this.performanceMesure = performanceMesure.setScale(DEFAULT_SCALE, BigDecimal.ROUND_DOWN);
        } else {
            this.performanceMesure = null;
        }
    }

}
